package com.module.base.picker

import android.content.Context
import com.module.base.utils.DisplayUtils
import com.bigkoo.pickerview.builder.OptionsPickerBuilder
import com.bigkoo.pickerview.listener.OnOptionsSelectListener
import com.bigkoo.pickerview.view.OptionsPickerView
import com.module.base.R


fun <T> getOptionsPickerView(
    context: Context,
    listener: OnOptionsSelectListener?
): OptionsPickerView<T> {
    val commonListPicker: OptionsPickerView<T> = getBuild(context, listener).build<T>()
    commonListPicker.findViewById(R.id.optionspicker)
        .setPadding(0, DisplayUtils.dip2px(10f), 0, DisplayUtils.dip2px(10f))
    return commonListPicker
}

/**
 * 默认配置
 */
fun getBuild(
    context: Context,
    listener: OnOptionsSelectListener?
): OptionsPickerBuilder {
    return OptionsPickerBuilder(context, listener)
        .setLineSpacingMultiplier(2.2f)
        .setItemVisibleCount(7)
        .setContentTextSize(16) //滚轮文字大小
        .setSubCalSize(16)
        .setSubmitColor(context.resources.getColor(R.color.bg_default)) //确定按钮文字颜色
        .setCancelColor(context.resources.getColor(R.color.color_picker)) //取消按钮文字颜色
        .setDividerColor(context.resources.getColor(R.color.color_line))
}